Prometheus by Brian Brazil

Prometheus by Brian Brazil

Author:Brian Brazil
Language: eng
Format: epub
Publisher: O'Reilly Media
Published: 2018-07-23T16:00:00+00:00


for _, g := range metrics.Gauges { name := invalidChars.ReplaceAllLiteralString(g.Name, "_") desc := prometheus.NewDesc(name, "Consul metric "+g.Name, nil, nil) ch <- prometheus.MustNewConstMetric( desc, prometheus.GaugeValue, float64(g.Value)) }

Processing of counters is similar, except that a _total suffix is added to the metric name:

for _, c := range metrics.Counters { name := invalidChars.ReplaceAllLiteralString(c.Name, "_") desc := prometheus.NewDesc(name+"_total", "Consul metric "+c.Name, nil, nil) ch <- prometheus.MustNewConstMetric( desc, prometheus.CounterValue, float64(s.Count)) }

The contents of metrics.Samples are more complicated. While the samples are a Prometheus summary, the Go client does not currently support those for MustNewConstMetric. Instead, you can emulate it using two counters. _seconds is appended to the metric name, and the sum is divided by a thousand to convert from milliseconds to seconds:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.